let app = getApp()
Page({
  data: {
    radarRefreshData: 0,
    radarBottomData: 0,
    clueRefreshData: 0,
    clueBottomData: 0,  
    titleArr: [ "雷达", "线索" ],
    cur: 0,
    page:1,
    page2:1,
    pageFlag:wx.getStorageSync('staff_bind_id'),
    radarRefreshData:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  choosetab:function(e){
    this.setData({
      cur:e.currentTarget.dataset.id,
      page:1,
      page2:1,
      clueRefreshData:[],
      radarRefreshData:[]
    })
    if(e.currentTarget.dataset.id==0){
      this.get_radardata();
    }else{
      this.get_msgdata(); 
    }
  },
  onLoad: function (options) {
    this.get_radardata();
    this.get_msgdata(); 
  },
  changedata:function(e){
    this.setData({
      page:1,
      page2:1,
      radarRefreshData:[],
      clueBottomData:[]
    })
    if(this.data.cur==0){
      this.get_radardata();
    }else{
      this.get_msgdata(); 
    }
   /*  var user_id=e.detail;
    var clueRefreshData=this.data.clueRefreshData
    var radarRefreshData=this.data.clueRefreshData
    for (var p = 0; p <clueRefreshData.length; p++) {
      if(clueRefreshData[p].user_id==user_id){
        clueRefreshData.splice(p, 1);
      }
   }
   for (var i = 0; i <radarRefreshData.length; i++) {
    if(radarRefreshData[i].user_id==user_id){
      radarRefreshData.splice(i, 1);
    }
  }
  this.setData({
     clueRefreshData:clueRefreshData,
     radarRefreshData:radarRefreshData
  })  */
  },
  get_msgdata:function(){
    var that=this
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'Customer_clue', 
        page:that.data.page2,
        staff_id:wx.getStorageSync('staff_bind_id')
      },
      success: function(res) {
        if(that.data.page2==1)
        {
          that.setData({
            clueRefreshData:res.data.info
          })
        }else
        {
          var clueRefreshData=that.data.clueRefreshData
          clueRefreshData=clueRefreshData.concat(res.data.info)
          that.setData({
            clueRefreshData:clueRefreshData
          })
        }
      }
    })
  },
  get_msgdata2:function(){
    var that=this
    wx.request({
      url: app.globalData.siteroot,
      data: {
        do:'Customer_clue', 
        page:that.data.page2,
        staff_id:wx.getStorageSync('staff_bind_id')
      },
      success: function(res) {
        if(res.data.info.length>0){
          that.setData({
            clueRefreshData:res.data.info
          })
        }
      }
    })
  },
  get_radardata:function(){
    var that=this
    wx.request({
        url: app.globalData.siteroot,
        data: {
          do:'Customer_radar',
          page:that.data.page, 
          staff_id:wx.getStorageSync('staff_bind_id')
        },
        success: function(res) {
            if(that.data.page==1)
            {
              that.setData({
                radarRefreshData:res.data.info
              })
            }else
            {
              var radarRefreshData=that.data.radarRefreshData
              radarRefreshData=radarRefreshData.concat(res.data.info)
              that.setData({
                radarRefreshData:radarRefreshData
              })
            }
        }
      })
   },
   get_radardata2:function(){
    var that=this
    wx.request({
        url: app.globalData.siteroot,
        data: {
          do:'Customer_radar',
          page:that.data.page, 
          staff_id:wx.getStorageSync('staff_bind_id')
        },
        success: function(res) {
          if(res.data.info.length>0){
            that.setData({
              radarRefreshData:res.data.info
            })
          }
        }
      })
   },
   onReachBottom: function () {
    var that=this
    if(this.data.cur==0){
      this.setData({
        page:parseInt(that.data.page)+1
     })
     this.get_radardata();
    }else{
      this.setData({
        page2:parseInt(that.data.page2)+1
     })
     this.get_msgdata();
    }
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function (e) {
    var that=this
    if(this.data.cur==0){
      this.setData({
        page:parseInt(that.data.page)+1
     })
     this.get_radardata2();
    }else{
      this.setData({
        page2:parseInt(that.data.page2)+1
     })
     this.get_msgdata2();
    }
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})